public class runningSum {
    public int[] runningSum(int[] nums) {
        //这不就是返回一个前缀和
        int[] res = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            res[i] = nums[i] + (i - 1 >= 0 ? res[i - 1] : 0);
        }
        return res;
    }


    public int[] runningSum1(int[] nums) {
        int[] dp = new int[nums.length];
        dp[0] = nums[0];
        for (int i = 1; i < nums.length; i++) {
            //状态转移
            dp[i] = dp[i - 1] + nums[i];
        }
        return dp;
    }
}
